<?php

namespace app\expbao\validate;

use think\Validate;

/**
 * 用户验证器
 * @package app\admin\validate
 * @author staroot <394454244@qq.com>
 */
class ExUser extends Validate
{
    //定义验证规则
    protected $rule = [
        'member_name|用户名' => 'require|unique:expbao_user',
        //'nickname|昵称'  => 'require',
        //'member_email|邮箱'     => 'email',
        'member_passwd|密码'  => 'require|length:6,20',
        'repasswd|重复密码'   => 'require|confirm:member_passwd',
        'member_mobile|手机号'   => 'require|regex:^1\d{10}',
    ];

    //定义验证提示
    protected $message = [
        'member_name.require' => '请输入用户名',
        'member_email.require'    => '邮箱不能为空',
        'member_email.email'      => '邮箱格式不正确',
        'member_email.unique'     => '该邮箱已存在',
        'member_passwd.require' => '密码不能为空',
        'member_passwd.length'  => '密码长度6-20位',
        'member_mobile.require'  =>'手机号不能为空',
        'member_mobile.regex'     => '手机号不正确',
        'repasswd.confirm'     =>'两次密码不一致',

    ];

    //定义验证场景
    protected $scene = [
        //更新
        'update'  =>  ['member_email', 'member_passwd' => 'length:6,20', 'member_mobile'],
        //登录
        'signin'  =>  ['member_name' => 'require', 'member_passwd' => 'require'],
    ];
}
